﻿using System;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;


namespace advadev.DataStorage.Demo.Web
{

    /// <summary>
    /// Represents the user validator for this service
    /// </summary>
    public class UserValidator : UserNamePasswordValidator
    {

        /// <summary>
        /// Validates the given user credentials
        /// </summary>
        /// <param name="userName">
        /// User name
        /// </param>
        /// <param name="password">
        /// Password
        /// </param>
        override public void Validate(string userName, string password)
        {
            string configUserName = "serviceUsername";
            string configPassword = "servicePassword";
            if (string.IsNullOrEmpty(configUserName) || string.IsNullOrEmpty(configPassword) ||
                userName != configUserName || password != configPassword)
            {
                throw new SecurityTokenValidationException("Authentication failed!");
            }
        }

    }

}